{template 'common/header'}
  <ul class="nav nav-tabs">    
    <li><a href="{php echo $this->createWebUrl('setCard');}">微信卡券</a></li>
    <li><a href="{php echo $this->createWebUrl('setMiicard');}">系统优惠券</a></li>
    <li class="active"><a href="{php echo $this->createWebUrl('setcardoff');}">卡券核销</a></li>
  </ul>
<div class="mii-box text-center">
	<div class="sobox">	
		<input type="text"  name="sokey" class="sokey" placeholder="请输入查询值">
		<button type="button" class="btn dropdown-toggle socard" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">查询</button>
	</div>
</div>
{if empty($i)}
<div class="panel-body we7-padding">
	<div class="form-horizontal">
		<div class="form-group">  
			<label class="col-sm-2 control-label">领取人:</label>
			<div class="col-sm-6 control-label" style="text-align: left;">
                {$o['uName']}/{$o['uPhone']}
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label">卡券编号:</label>
			<div class="col-sm-6 control-label" style="text-align: left;">
                {$o['card_on']}
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label">卡券类型:</label>
			<div class="col-sm-6 control-label" style="text-align: left;">
                {php echo cardname($o['card_type'])}
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-2 control-label">卡券信息:</label>
			<div class="col-sm-6 control-label" style="text-align: left;">
                {$o['title']}
			</div>
		</div>

        <div class="form-group">
            <label class="col-sm-2 control-label">使用期限:</label>
            <div class="col-sm-6 control-label" style="text-align: left;">
                {php echo date('Y.m.d',$o['starttime'])}-{php echo date('Y.m.d',$o['endtime'])}
            </div>
        </div> 

        <div class="form-group">
            <label class="col-sm-2 control-label">是否逾期:</label>
            <div class="col-sm-6 control-label" style="text-align: left;">
                {if $_W['timestamp']<$o['endtime']}<span class="label label-success">未逾期</span>{else}<span class="label label-danger">已逾期</span>{/if}
            </div>
        </div>        

        <div class="form-group">
            <label class="col-sm-2 control-label">是否使用:</label>
            <div class="col-sm-6 control-label" style="text-align: left;">
                {if $o['use']=='-1'}<span class="label label-success">未使用</span>{else}<span class="label label-danger">已使用</span>{/if}
            </div>
        </div> 

	 		<div class="form-group" style="border-top: #9c9c9c 1px solid;">
	 			<div class="col-sm-2 control-label">
	 				<!-- <button type="button" class="btn btn-success">确认完成</button> -->
	 			</div>
	 			<div class="col-sm-2 control-label">
	 				<button type="button" id="isok" ucid="{$o['id']}" sid = "{$o['use']}" class="btn btn-success isok" {if $o['use']=='1'}disabled="disabled"{else}{/if}>{if $o['use']=='1'}已核销{else}确认核销{/if}</button>
	 			</div>
	 		</div>	
	</div>
</div>
{elseif $i=='empty'}
<p class="bg-warning" style="text-align: center;height: 40px; display:block;width: 100%; line-height: 40px;">没有查询到该卡券编号信息。</p>
{/if}
<style type="text/css">
.right-content{padding: 0;}
.sobox{
    width: 450px;
    height: 70px;
    margin: auto;
    position: relative;
    display: block;
}
.border-l:{
    border-left: #666 1px solid;
}
.border-r:{
    border-right: : #666 1px solid;
} 
.list_th{
	height: 30px;	
	line-height: 30px;

}
.list_tr{
	height: 100px;	
	line-height: 100px;
}
.J_add{
	margin-top:25px;
}
.goods-img{
	width: 80px;
	height:80px;
	margin: 10px;
	display: block;
}
.isok{
    background: #5CA209;
}
.isoff{
    background: #9c9c9c;
}
.gl{
    height: 20px !important;
}
.td span{
    display: block;
}
.info{
    width: 100%;
    height: 25px;
    text-align: center;
    line-height: 25px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.td .left_padding {
    padding-left: 10px !important;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.ordertype{
	font-size: 14px;   
    border-radius: 2px;
    color: #FFFFFF;
    text-decoration: none;
    width: 60px;
    height: 25px;
    margin-left: auto;
    margin-right: auto;
    line-height: 25px;
}
.ordertype-pay{
	background: #ff5d38;
}
.ordertype-online{
    background: #666;
}
        .mii-top{
        height: 100px;
        width: 96%;
        background: #ff5d38;
        margin: 0px 2%;
        display: block;
        box-shadow: 0 4px 20px 0px rgba(0, 0, 0, 0.14), 0 7px 10px -5px rgba(255, 152, 0, 0.4);
    }
    .mii-box{
        width: 98%;
        height: 100px;
        line-height: 100px;
        margin-right: 1%;
        margin-left: 1%;
        background-color: #fff; 
    }
    .soisok{
        width: 100px;
        height: 35px;
        border-radius: 2px;
        border: 1px solid #ff5d38;
        background-image: none;
        box-shadow: 0 0 10px rgba(255,93,56,.6);
        text-align: center;
        outline: none;        
    }
    .soclass{
        width: 100px;   
        height: 35px;
        border-radius: 2px;
        border: 1px solid #ff5d38;
        background-image: none;
        box-shadow: 0 0 10px rgba(255,93,56,.6);
        text-align: center;
        outline: none;        
    }
    .sokey{
        width: 300px;
        height: 35px;
        border-radius: 2px;
        border: 1px solid #ff5d38;
        background-image: none;
        box-shadow: 0 0 10px rgba(255,93,56,.6);
        text-align: center;
        outline: none;
    }
    .socard{
        width: 100px;
        height: 35px;
        background-color: #ff5d38;
        color: #FFFFFF;
        border-radius: 2px;
        border:0;
        display: inline-block;
        padding: 8px 12px;
        box-sizing: border-box;
        box-shadow: 0 2px 2px 0 rgba(255,93,56, 0.14), 0 3px 1px -2px rgba(255,93,56, 0.2), 0 1px 5px 0 rgba(255,93,56, 0.12);    
        line-height: 0px;  
        outline: none;  
    }
    .submit:hover{
        box-shadow: 0 14px 26px -12px rgba(255,93,56, 0.42), 0 4px 23px 0px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(255,93,56, 0.2);
    }

</style>
<link rel="stylesheet" href="{MODULE_URL}public/css/Toast.css">
<script src="{MODULE_URL}public/js/Toast.js"></script> 
<script type="text/javascript">
    $('.socard').on("click",function(){
         var toSearchPage = "{php echo $this->createWebUrl('setcardoff');}&version_id="+"{$_GPC['version_id']}&card_on=";
         var key='';
         var key = $.trim($('.sokey').val());
         if(key==''){
            mqToast({type:1,context: '请输入要搜索的卡券编号'});  
            return false
         }else{
            window.location.href = toSearchPage + key;
         }
    })	

</script>
<script type="text/javascript">
    $(document).ready(function(){
         $(document).on('click','.isok',function(){
                $('#isok').addClass('disabled');
                var ucid = $(this).attr('ucid');
                var sid = $(this).attr('sid');
                if(sid !=1){
                    if(!confirm('您确认已完成该订单吗？')){
                        window.event.returnValue = false;
                    }else{
                        $.ajax({
                            url:"{php echo $this->createWebUrl('carduse');}&version_id="+"{$_GPC['version_id']}",
                            data:{ucid:ucid},
                            dataType:"json",
                            type:"post",
                            success:function(res){
                                if(res.status==1){
                                    mqToast({type:1,context: res.msg});
                                      setTimeout(function(){
                                        window.location.reload();
                                      },2000);
                                }else{
                                    mqToast({type:1,context: res.msg});
                                      setTimeout(function(){
                                        window.location.reload();
                                      },2000);                                    
                                }
                            }
                        })
                    }
                }else{
                    mqToast({type:1,context: '该订单已完成'});
                }
             })
    })       
</script>
{template 'common/footer'}